﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace UnnamedPodcastLibrary
{
    [DebuggerDisplay("{DownloadUrl}")]
    public class Feed : IEquatable<Feed>
    {
        public Feed(Uri downloadUrl)
        {
            this.DownloadUrl = downloadUrl;
            this.Episodes = new List<Episode>();
        }
        public string State { get; set; }
        public Uri DownloadUrl { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public List<Episode> Episodes { get; private set; }
        public Uri ImageUrl { get; set; }
        public string ImageLocalFileName { get; set; }

        public override bool Equals(object obj)
        {
            var other = obj as Feed;
            if (other == null)
                return false;
            return this.Equals(other);
        }
        public bool Equals(Feed other)
        {
            if (other == null)
                return false;
            if (object.ReferenceEquals(this, other))
                return true;
            return this.DownloadUrl.OriginalString.Equals(other.DownloadUrl.OriginalString, StringComparison.OrdinalIgnoreCase);
        }

        public override int GetHashCode()
        {
            return this.DownloadUrl.OriginalString.GetHashCode();
        }

        public static bool operator ==(Feed a, Feed b)
        {
            if (System.Object.ReferenceEquals(a, b))
                return true;

            if (((object)a == null) || ((object)b == null))
                return false;

            return a.Equals(b);
        }

        public static bool operator !=(Feed a, Feed b)
        {
            return !(a == b);
        }
    }

}
